package com.chalk.mall.demo;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

import java.util.Arrays;

/**
 * @author xiaoqiang
 * @Description 项目入口
 * @date 2019/2/28 10:57
 */
@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx){
        return args -> {
            System.out.println("查看springboot加载的bean:");
            String [] beanNames = ctx.getBeanDefinitionNames();
            // 排序
            Arrays.sort(beanNames);
            for (String beanName : beanNames){
                System.out.println("--beanNaem--:" + beanName);
            }
        };
    }


}
